home *** CD-ROM | disk | FTP | other *** search
- rt.doc
-
- NAME
- rt - enable resource tracking
-
- VERSION
- V0.1b - 12-07-96
-
- SYNOPSIS
- rt Config/A,Debug/S
-
- REQUIREMENTS
- - AmigaOS 3.0 (V39) or higher
- - a basic 68000 system should run rt alright, but it increases the OS
- overhead, so a 68020 or better is recommended
-
- OPTIONS
- Config/A : This parameter is required. It specifies the config file
- from which rt should read its patching info.
- Debug/S : Specifying this switch makes rt print a lot of garbage
- (also called "debugging information") while parsing the
- config file and doing its patchwork. Without the Debug
- switch, only error messages are printed.
-
- DESCRIPTION
- "rt" is an attempt at resource tracking on AmigaOS. This means the
- system manages lists of all sorts of resources that are currently
- allocated. If a task dies, its resources can be given back to the
- system. UNIX is very good at this, mainly due to its virtual memory
- system you can kill a task and in most cases it gives back everything
- it ever allocated. Although a couple of approaches have been made in
- the last years, AmigaOS still has a lot of problems with it. Resource
- tracking was left out of the first AmigaOS versions for performance
- and memory reasons but still wasn't added later when CPU power and RAM
- prices would have made it possible. Probably Commodore noticed it
- would become hacky :-)
- Compared to other systems of the sort, rt has the advantage of being
- able to patch virtually any OS function. Everything it needs to know
- it reads from a config file, so new resources can be added to the
- tracker without doing any coding.
- See techinfo.doc for detailed info on how the program works!
- Simply spoken, rt manages a couple of lists containing deallocation
- info for every tracked resource. Every resource to be tracked has to
- be specified on a line in the config file. The ReadArgs template for
- these lines is as follows:
-
- Library/A,AllocOff/N/A,FreeOff/N/A,AllocReg/A,SaveAfter/N/A,
- ErrorVal/N/A,FreeReg/A,Resources/N/A,DescOffset/N/A
-
- The parameters in detail:
- Library : name of the library to be patched
- AllocOff : LVO of the allocation function (positive)
- FreeOff : LVO of the deallocation function (positive)
- AllocReg : the register to get the resource pointer from
- in the allocation function
- SaveAfter : "0" to save the given register before allocation
- "1" to save after allocation
- ErrorVal : return value to consider an allocation failure
- FreeReg : register where to pass the resource pointer to the
- deallocation function
- Resources : estimated number of open resources under rt control
- in normal system operation. This number is not really
- important, it just increases efficiency if you get it
- right.
- DescOffset: Structure offset of a pointer to a descriptive string
- inside the resource structure.
- See the example if you don't really know what all this crap means :-)
- Here it is:
-
- EXAMPLE
- Say you want to track all screens. The "allocation function" for
- screens resides in intuition.library and is called
- OpenScreenTagList(). There's also an old function called OpenScreen()
- for compatibility with pre-2.0 software but the TagList version is
- used much more often in times OS3.0 (OpenScreen() may be patched
- separately). Deallocation is done by CloseScreen() in the same
- library. Now grab your favorite FD parser and determine these
- functions' LVOs (this will probably become easier if I decide to add
- an own FD parser to rt). They're -612 and -66 respectively here. We
- now have the first three parameters in the configfile line:
- intuition.library 612 66
- Notice the lacking sign - all LVOs are negative so the minus was
- omitted.
- Next is "AllocReg" and "SaveAfter" - the register where we're going
- to find a pointer to the resource before or after the allocation
- function - and the time when to save this register to the
- ResourceNode. The AutoDocs tell you that OpenScreenTagList() returns a
- pointer to the screen structure in d0 which means we have to save d0
- *after* the OpenScreenTagList() call. That's our next two config
- parameters:
- intuition.library 612 66 d0 1
- But we need to tell the patch when to add a resource to the
- "allocated" list - that is, if the allocation really succeeded.
- That's what the parameter "ErrorVal" does. Consulting the AutoDocs
- again tells you that OpenScreenTagList() returns a NULL pointer to
- indicate an error. Currently rt can only check a returncode in
- register d0, no matter which register will be saved as the resource
- pointer, which should be OK for most functions but will probably be
- extended to support whole ranges of errorvalues and different
- registers. OK, this NULL pointer is our errorvale, which makes the
- config line:
- intuition.library 612 66 d0 1 0
- The parameter "FreeReg" works just like AllocReg - it specifies the
- register where the deallocation function expects the resource pointer.
- In our case, this is a0 - guess what, that's from the AutoDocs!
- The last two parameters are the most confusing ones :-) :
- "Resources" gives the estimated number of resources of this type that
- are under control of rt in normal system operation. This number is not
- critical at all but the better it fits the more efficient rt will run.
- Too high values will waste memory (not much though, if you specify 100
- resources but normally use only 20, you'll have wasted
- (100-20)*16=1280 bytes), too low values will slow rt down a tiny bit
- and increase memory fragmentation.
- For the technically interested: Resources * sizeof(RsrcNode) is the
- pool size for the function's private memory pool.
- For screens, a sensible value is ~5-10. You'll seldom have more than
- 5 screens open and hardly ever 10.
- "DescOffset" is the offset into a resource structure where a pointer
- to a descriptive string can be found. A lot of resources have such
- strings - screens and windows have a title-text, libraries and devices
- have a name pointed to by their Node field etc. The rtFreeresources
- program uses this field to give you a more information about a
- specific resource when asking you whether to free it or not.
- For Screens, the pointer to the title-text can be found in the screen
- structure at offset 22. If your resource has no such string (like
- AmigaDOS filehandles for example), enter a zero here.
- That completes the configfile line:
- intuition.library 612 66 d0 1 0 a0 10 22
-
- BUGS
- - An allocation function can only have a single errorvalue in d0.
- - The config file parser is not very smart.
- - Not enough sanity checks for the config. Be careful what you patch!
- - Some functions may not be patched at all. This is not really a bug
- but an (IMHO) inevitable weakness of the concept. These functions
- include:
- - Most memory allocation functions (AllocMem()/FreeMem()/
- AllocPooled()/FreePooled()). AllocVec()/FreeVec() and
- AllocRemember()/FreeRemember() might work though.
- - functions that are legal to call from interrupts (signalling etc.)
- As these function seldom allocate stuff this shouldn't really be
- a problem.
- - Well, it's a beta... 8-)
-
- HISTORY
- V0.1b (12-07-96): First Release
-
- TODO
- - implement more versatile error checks for alloc function
- - FD-file parser to calculate LVOs from function names in the cfg file
- - better docs (AmigaGuide)
- - include predefined functions to install via configfile-macro
-
- AUTHOR
- Matthias Bethke
- Giessener Strasse 31
- 35457 Lollar
- Germany
- AmigaNet : Matthias Bethke@39:176/208.0
- Usenet : postmaster@sweetdreams.lahn.de
- or : Matthias.Bethke@sowi.uni-giessen.de
-